

"""win"""
wordfile = open(r"E:\project_python\NewN\NLP\words.txt",'r+',encoding='UTF-8')
onewFile = open(r"E:\project_python\NewN\NLP\Reader\1w.txt","w",encoding='UTF-8')
twoFile = open(r"E:\project_python\NewN\NLP\Reader\2w.txt","w",encoding='UTF-8')
threeFile = open(r"E:\project_python\NewN\NLP\Reader\3w.txt","w",encoding='UTF-8')
fourFile = open(r"E:\project_python\NewN\NLP\Reader\4w.txt","w",encoding='UTF-8')
fiveFile = open(r"E:\project_python\NewN\NLP\Reader\5w.txt","w",encoding='UTF-8')
sixFile = open(r"E:\project_python\NewN\NLP\Reader\6w.txt","w",encoding='UTF-8')
"""linux"""
# wordfile = open(r"/root/NewN/NLP/words.txt",'r+',encoding='UTF-8')
# onewFile = open(r"/root/NewN/NLP/Reader/1w.txt","w",encoding='UTF-8')
# twoFile = open(r"/root/NewN/NLP/Reader/2w.txt","w",encoding='UTF-8')
# threeFile = open(r"/root/NewN/NLP/Reader/3w.txt","w",encoding='UTF-8')
# fourFile = open(r"/root/NewN/NLP/Reader/4w.txt","w",encoding='UTF-8')
# fiveFile = open(r"/root/NewN/NLP/Reader/5w.txt","w",encoding='UTF-8')
# sixFile = open(r"/root/NewN/NLP/Reader/6w.txt","w",encoding='UTF-8')
wordlist = []

#拿出所有词
for word in wordfile.readlines():
    word = word.strip()
    wordlist.append(word)
print(len(wordlist))
#判断有几个空格并且输出
onewordList = []
twowordList = []
threewordList = []
fourwordList = []
fivewordList = []
sixwordList = []
for word in wordlist:
    spaceNum = word.count(' ')
    if spaceNum == 0 :
        onewordList.append(word)
        print(word,file=onewFile)
        continue
    if spaceNum == 1 :
        twowordList.append(word)
        print(word, file=twoFile)
        continue
    if spaceNum == 2 :
        threewordList.append(word)
        print(word, file=threeFile)
        continue
    if spaceNum == 3 :
        fourwordList.append(word)
        print(word, file=fourFile)
        continue
    if spaceNum == 4 :
        fivewordList.append(word)
        print(word, file=fiveFile)
        continue
    if spaceNum == 5 :
        sixwordList.append(word)
        print(word, file=sixFile)
        continue

print(len(onewordList) + len(onewordList) + len(onewordList) + len(onewordList) + len(onewordList) + len(onewordList))
if len(onewordList) + len(twowordList) + len(threewordList) + len(fourwordList) + len(fivewordList) + len(sixwordList) == 967 :
    print("1-6词单词List分配成功")
